Path 1: 6 calls (1.0)

None (6)

1def generator() -> t.Generator:
2        ctx = _cv_request.get(None)
3        if ctx is None:
4            raise RuntimeError(
5                "'stream_with_context' can only be used when a request"
6                " context is active, such as in a view function."
7            )
8        with ctx:
9            # Dummy sentinel.  Has to be inside the context block or we're
10            # not actually keeping the context around.
11            yield None
12
13            # The try/finally is here so that if someone passes a WSGI level
14            # iterator in we're still running the cleanup logic.  Generators
15            # don't need that because they are closed on their destruction
16            # automatically.
17            try:
18                yield from gen
19            finally:
20                if hasattr(gen, "close"):
21                    gen.close()